﻿import QtQuick                  2.3
import QtQuick.Controls         2.12
import QtQuick.Controls.Styles  1.4

import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0

import XUI 1.0

Button {
    id:             control
    hoverEnabled:   true
    focusPolicy:    Qt.ClickFocus
    height:         globalData.buttonHeight
    width:          ScreenTools.defaultFontPixelHeight * 6

    property alias  iconSource:         _image.source
    property real   imageScale:         0.6
    property real   pointSize:          ScreenTools.defaultFontPointSize
    property bool   _showHighlight:     pressed | hovered | checked

    property real _margin: 5

    background: Item {
    }

    contentItem: Rectangle {
        anchors.fill:   parent
        color:          checked ? XGlobalColor.theme : "transparent"

        Row {
            height:                     parent.height
            // anchors.centerIn:           parent

            // Item {
            //     id:     iamgeItem
            //     height: parent.height
            //     width:  height
                // Row {
                    spacing:  _margin
                    anchors.centerIn:       parent
                    // Item {
                    //     width: _margin * 5
                    //     height: 1
                    // }
                    Image/*QGCColoredImage*/ {
                        id:                     _image
                        smooth:                 true
                        mipmap:                 true
                        antialiasing:           true
                        // color:                  checked ? "white" : "white"
                        height:                 parent.height * imageScale
                        width:                  height
                        fillMode:               Image.PreserveAspectFit
                        sourceSize.height:      height
                        anchors.verticalCenter: parent.verticalCenter
                    }
                    Item {
                        width: 1
                        height: 1
                    }
                    XLabel {
                        text:                       control.text
                        color:                      "white"
                        anchors.verticalCenter:     parent.verticalCenter
                    }
                // }
            // }
        }
    }
}

